<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // event loop
        // 同步>微任务>宏任务
        console.log('a');
        setTimeout(() => {
            console.log(1);// 同步
            setTimeout(() => {
                console.log(0);//宏任务 异步
            })
            new Promise((resolve) => {
                console.log(2);// 同步
                resolve(); // 同步？
            }).then(() => {
                console.log(3);//微任务 异步
            });
            console.log(4);// 同步

        }, 100);
        console.log('b');

    </script>

</body>

</html>